<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('menu', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('pid')->comment("父ID");
            $table->string('title', 50)->comment('菜单名');
            $table->string('icon', 50)->comment('图标');
            $table->string('uri', 50)->comment('地址');
            $table->unsignedSmallInteger('order')->comment('排序');
            $table->timestamps();
        });
        DB::statement("ALTER TABLE `menu` comment '菜单'");

        Schema::create('org_menu', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('org_id')->comment("机构id");
            $table->unsignedBigInteger('menu_id')->comment("菜单id");
        });
        DB::statement("ALTER TABLE `org_menu` comment '机构菜单'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('menu');
        Schema::dropIfExists('org_menu');
    }
};
